<template>
	<view>
		<view class="bottom">
			<button class="upload_button" @tap="add">
				<u-icon name="plus" color="#fff"></u-icon>
				新增
			</button>
		</view>
		<!-- <app-tabs type="2" :list="tabsList" @change="tabsChange" /> -->
		<view class="list">
			<view class="item" v-for="(item ,index) in list" :key="index"  >
				<image class="img" :src="item.url"></image>
				<view class="text" @click="getById(item.id)">
					<view>名称:{{item.yhjmc}}</view>
					<view>有效期:{{item.kssj.slice(0,10)}}至{{item.jssj.slice(0,10)}}</view>
					<view>数量:{{item.num}}</view>
					<view>已发放:{{item.synum}}</view>
				</view>
			</view>
		</view>
		<Addlist ref="addRef" bg="" @getList="getList" />
	</view>
</template>

<script>
	import Addlist from './AddYhj.vue';
	export default {
		components: {
			Addlist
		},
		data() {
			return {
				tabsList: ['已使用', '未使用'],
				list: [],
				id: null,
				hdid:'',
			}
		},
		onLoad(options) {
			this.id = options.id
			this.sjid = options.sjid
			// this.getById();
			this.getList();
		},
		methods: {
			getById(item){
				uni.navigateTo({
					url:'/pages/sjhd/detail?id='+item+'&sjid='+this.sjid
				})
			},
			add() {
				this.$refs.addRef.open(this.id,this.sjid);
				console.log('新增')
			},
			/**
			 * tabs 切换
			 */
			tabsChange() {

			},
			getList(){
				this.$http.post('/app/pay/getYhjList', {
					hdid:this.id,
					page:1,
					limit:999,
				}).then(res => {
					console.log(res.page.records)
					this.list = res.page.records
				})
			},
			
			
		}
	}
</script>

<style lang="scss" scoped>
	.bottom {
		// width: 80%;
		margin: 30rpx auto;

		.upload_button {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 650rpx;
			height: 88rpx;
			color: #333;
			font-family: PingFangSC;
			color: #ffffff;
			font-weight: 500;
			font-size: 32rpx;
			padding: 0;
			border-radius: 50px;
			background: linear-gradient(90deg, #13b1a2 0%, #276329 100%);
			border: none;
		}
	}

	.list {
		width: 100vw;
		display: flex;
		flex-direction: column;
		align-items: center;

		.item {
			margin: 14rpx 0;
			width: 700rpx;
			position: relative;

			box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1), 0 8rpx 16rpx rgba(0, 0, 0, 0.1);
			padding: 20rpx;

			box-sizing: border-box;
			background: #fff;
			border-radius: 20rpx;
			display: flex;

			.img {
				width: 180rpx;
				height: 180rpx;
				border-radius: 20rpx;
			}

			.text {
				margin-left: 20rpx;
				color: #333;

				// position: relative;
				// top: -155rpx;
				// left: 190rpx;
			}
		}
	}
</style>